from langchain.prompts import (
    PromptTemplate,
    ChatPromptTemplate,
    HumanMessagePromptTemplate,
    SystemMessagePromptTemplate,
    MessagesPlaceholder
)
from langchain_core.messages import AIMessage, HumanMessage
from MyLangChain import get_llm

# llm = get_llm()

# template = PromptTemplate.from_template("给我讲个关于{subject}的笑话")
# print("===Template===")
# print(template)
# print("===Prompt===")
# print(template.format(subject='小明'))

# template = ChatPromptTemplate.from_messages(
#     [
#         SystemMessagePromptTemplate.from_template("你是{product}的客服助手。你的名字叫{name}"),
#         HumanMessagePromptTemplate.from_template("{query}"),
#     ]
# )
# print(template)
#
# prompt = template.format_messages(
#     product="AGI课堂",
#     name="瓜瓜",
#     query="你是谁"
# )
# print(prompt)

#
# ret = llm.invoke(prompt)
# print(ret)
# print(ret.content)

# human_message_template = HumanMessagePromptTemplate.from_template("Translate your answer to {language}.")
#
# chat_prompt = ChatPromptTemplate.from_messages(
#     # variable_name 是 message placeholder 在模板中的变量名
#     # 用于在赋值时使用
#     [MessagesPlaceholder(variable_name="conversation"), human_message_template]
# )
#
# human_message = HumanMessage(content="Who is Elon Musk?")
# ai_message = AIMessage(content="Elon Musk is a billionaire entrepreneur, inventor, and industrial designer")
#
# messages = chat_prompt.format_prompt(
#     # 对 "conversation" 和 "language" 赋值
#     conversation=[human_message, ai_message], language="日文"
# )
#
# print(messages.to_messages())


template = PromptTemplate.from_file("example_prompt_template.txt")
print("===Template===")
print(template)
print("===Prompt===")
print(template.format(topic='黑色幽默'))

